package com.tuozixuan.forest.api.impl;

import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;

import com.tuozixuan.forest.api.UserApi;
import com.tuozixuan.forest.dto.UserDTO;

@RestController
public class UserApiImpl implements UserApi {
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public String getUserNameById(String id) {
		logger.info("id:{}", id);
		return "lisi";
	}

	@Override
	public List<String> getUserNamesByIds(String[] ids) {
		logger.info("ids size:{}", ids.length);
		return Arrays.asList("zhangsan", "lisi");
	}

	@Override
	public boolean addUser(UserDTO userDTO) {
		logger.info("id:{} userName:{}", userDTO.getId(), userDTO.getUserName());
		return true;
	}

	@Override
	public boolean addUserWithException(UserDTO userDTO) {
		if ("1".equals(userDTO.getId())) {
			throw new RuntimeException("test");
		}
		return false;
	}

}
